var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  LocalPlayerView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.list_local_player.vScrollBarSkin = ""),
        (t.list_local_player.selectEnable = !0),
        (t.list_local_player.renderHandler = new Handler(
          t,
          t.updateRenderItemFn
        )),
        t.list_local_player.on(Laya.Event.CLICK, t, t.onDidClickItemAction),
        (t.list_local_player.scrollBar.changeHandler = new Handler(
          t,
          t.onLoadMorePlayerData
        )),
        (t.list_local_player.scrollBar.elasticDistance = 0),
        (t.list_local_player.scrollBar.elasticBackTime = 0),
        t.btn_local_back.on(Laya.Event.CLICK, t, t.onLocalBack),
        WebSocketService.addListener(
          { caller: t, code: 717, method: t.onLoadLocalPlayerDataFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: t, code: 1024, method: t.onLoadMakeFriendsFn },
          !0
        ),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openLocalPlayer = function () {
        return (
          null == this.localPlayerVC && (this.localPlayerVC = new t()),
          (this.localPlayerVC.list_local_player.visible = !1),
          WebSocketService.send({ c: 717, d: { pageNum: 0 } }),
          this.localPlayerVC
        );
      }),
      (t.prototype.onDidClickItemAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_local_player.selectedItem;
          "item_siliao" == e.target.name
            ? PrivateChatDialog.showPrivateMsgDialog(t)
            : "item_plus" == e.target.name
            ? WebSocketService.send({ c: 1024, d: { roleid: t.id } })
            : "item_pk" == e.target.name
            ? Fight.WaitFight.pk(t.id)
            : "item_qc" == e.target.name
            ? Fight.WaitFight.open(t.id, t.name)
            : FriendsDetailDialog.showFriendDialog(t.id, !0);
        }
      }),
      (t.prototype.onLoadMakeFriendsFn = function (e) {
        0 == e.code ? ToastView.toastView(e.data) : ToastView.toastView(e.msg);
      }),
      (t.prototype.updateRenderItemFn = function (e, t) {
        var i = e.dataSource,
          a = e.getChildByName("item_siliao"),
          l = e.getChildByName("item_plus"),
          o = e.getChildByName("item_pk"),
          r = e.getChildByName("item_qc"),
          n = e.getChildByName("item1");
        i.id == Global.roleId
          ? ((a.visible = !1),
            (l.visible = !1),
            (o.visible = !1),
            (r.visible = !1),
            (n.visible = !0))
          : ((a.visible = !0),
            (l.visible = !0),
            (o.visible = !0),
            (r.visible = !0),
            (n.visible = !1));
      }),
      (t.prototype.onLoadLocalPlayerDataFn = function (e) {
        if (0 == e.code) {
          if (this.currentPage >= 1) {
            if (0 == e.list.length) return void this.currentPage--;
            for (l = 0; l < e.list.length; l++) {
              var t = e.list[l];
              this.dataArr.push(t);
            }
          } else this.dataArr = e.list;
          var i = [];
          (this.isloading = !1),
            (this.label_local_player.text = "本地玩家（" + e.sum + ")");
          for (var a, l = 0; l < e.list.length; l++) {
            var o = e.list[l];
            (a =
              o.id == Global.roleId
                ? {
                    item1: { text: o.name + " Lv-" + o.lvl + "  ID:" + o.id },
                    item0: { text: "" },
                    head_img: { skin: this.dealHeadImg(o.type, o.sex) },
                    id: o.id,
                    name: o.name,
                  }
                : {
                    item0: { text: o.name + " Lv-" + o.lvl + "  ID:" + o.id },
                    item1: { text: "" },
                    head_img: { skin: this.dealHeadImg(o.type, o.sex) },
                    id: o.id,
                    name: o.name,
                  }),
              i.push(a);
          }
          (this.list_local_player.array = i),
            (this.list_local_player.visible = !0);
        }
      }),
      (t.prototype.onLoadMorePlayerData = function (e) {
        var t = e / this.list_local_player.scrollBar.max,
          i = new Date(),
          a = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (a = !0),
          1 == t && 0 == this.isloading && a)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({ c: 717, d: { pageNum: this.currentPage } }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (t.prototype.dealHeadImg = function (e, t) {
        var i = e + "" + t;
        return "comp/hreoImg/" + Dictionary.wsImgname[i] + ".png";
      }),
      (t.prototype.onLocalBack = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.FriendMomentController.LocalPlayerViewUI);
